package com.slw.caiji.controller;


import com.slw.caiji.Vo.params.PageParams;
import com.slw.caiji.dto.SysUser;
import com.slw.caiji.service.SysUserService;
import com.slw.caiji.utils.Result;
import io.swagger.annotations.Api;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping("/api/user")
@Api(tags = "用户管理")
public class SysUserController {

    @Autowired
    private SysUserService sysUserService;

    @PostMapping("list")
    @Operation(summary = "分页获取用户列表", description = "分页获取用户列表")
    public Result getList(@RequestBody PageParams pageParams) {
        return sysUserService.getSysUserList(pageParams);
    }


    @PostMapping("add")
    @Operation(summary = "新增用户", description = "新增用户")
    public Result addUser(@RequestBody SysUser sysUser) {
        return sysUserService.addUser(sysUser);
    }

    @GetMapping("del")
    @Operation(summary = "删除用户", description = "删除用户")
    public Result delUser(@RequestParam String ids) {
        return sysUserService.delUser(ids);
    }

    @GetMapping("detail")
    @Operation(summary = "用户详情接口", description = "获取用户详情")
    public Result detailUser(@RequestParam String id) {
        return sysUserService.detailUser(id);
    }

    @PostMapping("update")
    @Operation(summary = "更新用户接口", description = "编辑用户信息")
    public Result updateUser(@RequestBody SysUser sysUser) {
        return sysUserService.updateUser(sysUser);
    }
}
